package com.leixiaoqiao.dao.impl;

import com.leixiaoqiao.dao.CustomerDao;
import com.leixiaoqiao.pojo.Customer;
import com.leixiaoqiao.util.SqlSessionUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.HashMap;
import java.util.List;

public class CustomerDaoImpl implements CustomerDao {
    private CustomerDao customerDao;
    public CustomerDaoImpl(){
        SqlSession session = SqlSessionUtil.getSession();
        customerDao = session.getMapper(CustomerDao.class);
    }

    @Override
    public void addCustomer(Customer customer) {
        customerDao.addCustomer(customer);
    }

    @Override
    public void deleteCustomerById(int id) {
        customerDao.deleteCustomerById(id);
    }

    @Override
    public void updateCustomer(Customer customer) {
        customerDao.updateCustomer(customer);
    }

    //带条件的查询全部
    @Override
    public List<Customer> findList(HashMap<String, Object> queryMap) {
        return customerDao.findList(queryMap);
    }

    @Override
    public Customer findCustomerById(int id) {
        return customerDao.findCustomerById(id);
    }
}
